home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / ISRCLINE.ICN < prev    next >
Text File  |  1992-10-12  |  1KB  |  46 lines

  1. ############################################################################
  2. #
  3. #    File:     isrcline.icn
  4. #
  5. #    Subject:  Program to count code lines in Icon program
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 27, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  This program counts the number of lines in a Icon program that actually
  14. #  contain code, as opposed to being comments or blank lines.
  15. #
  16. ############################################################################
  17. #
  18. #  Links:  numbers
  19. #
  20. ############################################################################
  21.  
  22. link numbers
  23.  
  24. procedure main()
  25.    local total, chaff, code, line
  26.  
  27.    total := chaff := 0
  28.  
  29.    while line := read() do {
  30.       total +:= 1
  31.       line ? {
  32.          tab(many(' \t'))
  33.          if ="#" | pos(0) then chaff +:= 1
  34.          }
  35.       }
  36.  
  37.    code := total - chaff
  38.  
  39.    write(left("total lines:", 17), right(total, 6))
  40.    write(left("code lines:", 17), right(code, 6))
  41.    write(left("non-code lines:", 17), right(chaff, 6))
  42.    write()
  43.    write(left("percentage code:", 17), fix(100 * code, total, 7, 2))
  44.  
  45. end
  46.